widget: Use early-out style in gtk_widget_realize()
authorTimm Bäder <mail@baedert.org>
Sun, 19 Apr 2020 17:45:07 +0000 (19:45 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 5 May 2020 06:20:09 +0000 (08:20 +0200)
This is much more common in the current code base and reduces the
indentation level by one.

gtk/gtkwidget.c

index 8ee76a263d82edfc690ccfb9842508b1f75d4a01..a0ad576816c4002e3b0d0eec18da14fcf45e7d0a 100644 (file)
@@ -3463,41 +3463,41 @@ gtk_widget_realize (GtkWidget *widget)
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  if (!_gtk_widget_get_realized (widget))
-    {
-      gtk_widget_push_verify_invariants (widget);
+  if (priv->realized)
+    return;
 
-      /*
-       if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
-         g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
-      */
+  gtk_widget_push_verify_invariants (widget);
 
-      if (priv->parent == NULL && !GTK_IS_ROOT (widget))
-        g_warning ("Calling gtk_widget_realize() on a widget that isn't "
-                   "inside a toplevel window is not going to work very well. "
-                   "Widgets must be inside a toplevel container before realizing them.");
+  /*
+    if (GTK_IS_CONTAINER (widget) && _gtk_widget_get_has_surface (widget))
+    g_message ("gtk_widget_realize(%s)", G_OBJECT_TYPE_NAME (widget));
+  */
 
-      if (priv->parent && !_gtk_widget_get_realized (priv->parent))
-       gtk_widget_realize (priv->parent);
+  if (priv->parent == NULL && !GTK_IS_ROOT (widget))
+    g_warning ("Calling gtk_widget_realize() on a widget that isn't "
+               "inside a toplevel window is not going to work very well. "
+               "Widgets must be inside a toplevel container before realizing them.");
 
-      g_signal_emit (widget, widget_signals[REALIZE], 0);
+  if (priv->parent && !_gtk_widget_get_realized (priv->parent))
+    gtk_widget_realize (priv->parent);
 
-      if (priv->multidevice)
-        {
-          GdkSurface *surface = gtk_widget_get_surface (widget);
+  g_signal_emit (widget, widget_signals[REALIZE], 0);
 
-          gdk_surface_set_support_multidevice (surface, TRUE);
-        }
+  if (priv->multidevice)
+    {
+      GdkSurface *surface = gtk_widget_get_surface (widget);
 
-      gtk_widget_update_alpha (widget);
+      gdk_surface_set_support_multidevice (surface, TRUE);
+    }
 
-      if (priv->context)
-       gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
-      else
-        gtk_widget_get_style_context (widget);
+  gtk_widget_update_alpha (widget);
 
-      gtk_widget_pop_verify_invariants (widget);
-    }
+  if (priv->context)
+    gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
+  else
+    gtk_widget_get_style_context (widget);
+
+  gtk_widget_pop_verify_invariants (widget);
 }
 
 /**